﻿
using System;
using System.IO;

using NUnit.Framework;

namespace IronLua.Tests {

	public abstract class AbstractTestFixture {

		public abstract string Folder {
			get;
		}

		protected static string Normalize (string s)
		{
			return s.Trim ().Replace ("\r\n", "\n");
		}

		protected string GetTestCasePath (string file)
		{
			return Path.Combine (FindTestCasesDirectory (), Path.Combine (Folder, file));
		}

		static string FindTestCasesDirectory ()
		{
			string currentPath = Environment.CurrentDirectory;
			while (!Directory.Exists (Path.Combine (currentPath, "TestCases"))) {
				string oldPath = currentPath;
				currentPath = Path.GetDirectoryName (currentPath);
				Assert.AreNotEqual (oldPath, currentPath);
			}
			return Path.Combine (currentPath, "TestCases");
		}
	}
}